<?php 
    //    ELGG courses admin panel page

    // Run includes
        require_once(dirname(dirname(dirname(__FILE__)))."/includes.php");
        require_once("lib.php");
        require_once(dirname(dirname(__FILE__))."/common.php");
        
    // Initialise functions for user details, icon management and profile management
        run("admin:init");

        define("context", "admin");
        templates_page_setup();
        if (!isadmin()){
        	$body  = templates_draw( array(
                               'context' => 'admin',
                               'title' => $title,
                               'body' => "You must be an admin to access this page",
                               ));

			echo templates_page_draw(array($title, $body));

        	return;
        }

$method = required_param('method', PARAM_ALPHA);

switch ($method){
	case 'getskillcat':
		//check that date and courseid sent
		$scid = required_param('scid', PARAM_INT);
		$response = getAdminSkillCat($scid);
		break;
	case 'editskillcat':
		//check that date and courseid sent
		$scid = required_param('scid', PARAM_INT);
		$scName = required_param('scname', PARAM_NOTAGS);
		$response = editAdminSkillCat($scid,$scName);
		break;
	case 'deleteskillcat':
		//check that date and courseid sent
		$scid = required_param('scid', PARAM_INT);
		$response = deleteAdminSkillCat($scid);
		break;
	case 'addskillcat':
		//check that date and courseid sent
		$scName = required_param('scname', PARAM_NOTAGS);
		$response = addAdminSkillCat($scName);
		break;
	case 'removeskillskillcat':
		//check that date and courseid sent
		$scid = required_param('scid', PARAM_INT);
		$skillid = required_param('skillid', PARAM_INT);
		$response = removeAdminSkillSkillCat($skillid,$scid);
		break;
	case 'addskillskillcat':
		//check that date and courseid sent
		$scid = required_param('scid', PARAM_INT);
		$skillid = required_param('skillid', PARAM_INT);
		$response = addAdminSkillSkillCat($skillid,$scid);
		break;
	case 'getskill':
		//check that date and courseid sent
		$skillid = required_param('skillid', PARAM_INT);
		$response = getAdminSkill($skillid);
		break;
	case 'editskill':
		//check that date and courseid sent
		$skillid = required_param('skillid', PARAM_INT);
		$skillName = required_param('skillname', PARAM_NOTAGS);
		$skillURL = required_param('skillurl', PARAM_NOTAGS);
		$response = editAdminSkill($skillid,$skillName,$skillURL);
		break;
	case 'deleteskill':
		//check that date and courseid sent
		$skillid = required_param('skillid', PARAM_INT);
		$response = deleteAdminSkill($skillid);
		break;
	case 'addskill':
		//check that date and courseid sent
		$skillName = required_param('skillname', PARAM_NOTAGS);
		$response = addAdminSkill($skillName);
		break;
	case 'getcategories':
		//check that date and courseid sent
		$skillId = required_param('skillid', PARAM_INT);
		$response = getAdminCategories($skillId);
		break;
}
        
// set header to be XML
header('Content-Type: text/xml;');
$str = '<?xml version="1.0" encoding="UTF-8"?>';
$str .= '<response>';
if ($response) {
	$str .= responseToXML($response);
}
$str .= '</response>';

echo $str;
        
?>
